import { http } from '../../utils/net.js'
Page({
  data: {
    savingsCardList:[],
    currentCard:null,
    channelId: null,
    money: null
  },
  getDataFunc() {
    http({
      url:'/api/index/index?method=savings_card_list',
      isShowLoading:true,
      successCb:(res) => {
        if(res.data.length > 0) {
          this.setData({
            savingsCardList: res.data,
            currentCard: res.data[0]
          })
        }
      }
    })
  },
  toSelectCreditCard() {
    this.selectComponent("#myActionSheet").open()
  },
  selectCard(event) {
    console.log(event.currentTarget.dataset.hi)
    this.setData({
      currentCard: event.currentTarget.dataset.hi
    })
    this.selectComponent("#myActionSheet").close()
  },
  toConfirm() {
    if(!this.data.currentCard) {
      wx.showToast({
        title: '请选择到账储蓄卡',
        icon: "none"
      })
      return
    }
    if(channelId == 6) {

    }
    

  },
  confirmCloudSwiper() {
    http({
      url: "/api/index/index?method=cloud_brush",
      data: {
        channel_id: this.data.channelId,
        bc_id: this.data.bcId,
        card_id: this.data.currentCard.bc_id,
        money: this.data.money
      },
      isShowLoading: true,
      successCb: (res) => {
        console.log(res)
        if (res.data.is_jump_url == 1) {
          wx.navigateTo({
            url: '/pages/web/index',
            success: (res) => {
              res.eventChannel.emit('acceptDataFromOpenerPage', {
                url: res.data.jump_url,
                callback: function(){
                  wx.navigateTo({
                    url: "/pages/cloudSwiperRecord/index",
                  })
                }
              })
            }
          })
        }
      }
    })
  },
  onLoad: function (options) {
    console.log(options)

  },
  onReady: function () {

  },
  onShow: function () {
    this.getDataFunc()
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})